package com.lian.aieduc.config;

import jakarta.validation.Validation;
import jakarta.validation.Validator;
import jakarta.validation.ValidatorFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
@RequiredArgsConstructor
@Slf4j
public class WebConfig  implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 添加映射路径，允许所有路径跨域
        registry.addMapping("/**")
            // 允许所有来源跨域
            .allowedOriginPatterns("*")
            // 允许所有请求方法跨域
            .allowedMethods("*")
            // 允许所有请求头跨域
            .allowedHeaders("*")
            // 是否允许携带凭证（cookies）
            .allowCredentials(true);
    }


}
